package com.yfp.operation.service.impl;

import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yfp.operation.domain.SysDictData;
import com.yfp.operation.service.SysDictDataService;
import com.yfp.operation.mapper.SysDictDataMapper;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Optional;

/**
 *
 * @description 针对表【sys_dict_data(字典数据表)】的数据库操作Service实现
 * @createDate 2024-09-06 11:27:44
 */
@Service
public class SysDictDataServiceImpl extends ServiceImpl<SysDictDataMapper, SysDictData> implements SysDictDataService {

    @Resource
    private SysDictDataMapper sysDictDataMapper;

    @Override
    public SysDictData getByType(String dictType) {
        List<SysDictData> sysDictDataList = sysDictDataMapper.selectDictDataByType(dictType);
        SysDictData first = CollUtil.getFirst(sysDictDataList);
        return Optional.ofNullable(first).orElse(new SysDictData());
    }
}




